package it.mypofolio.report;

import it.mypofolio.model.Done;
import it.mypofolio.model.Stock;

/**
 * @author  Paolo Cappelletti (Gempliss Srl)
 */
public class ReportPlain implements Report{
	
	private double tot=0;

	@Override
	public void start() {
		System.out.println("Stock       \tSigla\tQty\tBuy\tCommiss\t\tTotBuy\t|\tCurrent\tHour\tAmount\tSALDO (con comm.)");
		System.out.println("------------------------------------------------------------------------------------------------------------------");
	}

	@Override
	public void printStock(Stock stock) {
		double amount=stock.getCurrentPrice()*stock.getQuantity();
		amount=(Math.round(amount*100)/100);
		double totbuy=stock.getBuyPrice()*stock.getQuantity();
		totbuy=(Math.round(totbuy*100)/100);
		double saldo=amount-totbuy-stock.getBuyCommission()-stock.getSellCommission();
		saldo=(Math.round(saldo*100)/100);
		
		String name=stock.getName();
		while(name.length()<10){
			name=name+" ";
		}
		System.out.println(name+"\t"+stock.getSigla()+"\t"+stock.getQuantity()+"\t"+stock.getBuyPrice()+"\t"+stock.getBuyCommission()+"/"+stock.getSellCommission()+"\t\t"+totbuy+"\t|\t"+stock.getCurrentPrice()+"\t"+stock.getCurrentPriceOra()+"\t"+amount+"\t"+saldo);
		tot=tot+saldo;
	}
	
	@Override
	public void printDone(Done st) {
		System.out.println(st.getName()+"\t\t\t\t\t\t\t\t\t\t\t"+st.getTot());
		tot=tot+st.getTot();
	}

	@Override
	public void end() {
		System.out.println("------------------------------------------------------------------------------------------------------------------");
		System.out.println("      TOTALE: \t\t\t\t\t\t\t\t\t\t\t"+(Math.round(tot*100)/100));
	}

	@Override
	public void endCurrent() {
		System.out.println("------------------------------------------------------------------------------------------------------------------");
		System.out.println("      TOTALE: \t\t\t\t\t\t\t\t\t\t\t"+(Math.round(tot*100)/100));		
	}



}
